package com.tcc.core.interceptor;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

/**
 * @Author: admin
 * @Description:
 * @Date: 2018/10/27 11:43
 */

@Aspect
public abstract class AbstractTccTransactionAspect {
    private TccTransactionInterceptor tccTransactionInterceptor;

    protected void setTccTransactionInterceptor(final TccTransactionInterceptor tccTransactionInterceptor) {
        this.tccTransactionInterceptor = tccTransactionInterceptor;
    }

    @Pointcut("@annotation(com.tcc.annotation.Tcc)")
    public void tccInterceptor() {
    }

    @Around("tccInterceptor()")
    public Object tccInterceptorMethod(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("--------------AbstractTccTransactionAspect::tccInterceptorMethod--------------------");
        return tccTransactionInterceptor.interceptor(proceedingJoinPoint);
    }

    public abstract int getOrder();
}
